package felix.multilauncher.Manager;

import android.text.TextUtils;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.util.ArrayList;
import java.util.List;

import felix.felixlib.util.SPUtil;
import felix.multilauncher.Bean.ContactBean;

/**
 * Created by huangmf on 10/9/2017.
 */

public class SpManager {
    private final static String TAG = SpManager.class.getName();
    private final static String ContactValue = "ContactValue";

    public static List<ContactBean> getContact() {
        String value = SPUtil.getStringValue(ContactValue, "");
        if (TextUtils.isEmpty(value)) {
            return new ArrayList<>();
        }
        List<ContactBean> contactBeen = new Gson().fromJson(value, new TypeToken<List<ContactBean>>() {
        }.getType());
        if (contactBeen != null) {
            return contactBeen;
        } else {
            return new ArrayList<>();
        }
    }

    public static void saveContact(List<ContactBean> contactBeen) {
        String value = new Gson().toJson(contactBeen);
        SPUtil.putStringValue(ContactValue, value);
    }
}
